import chromadb
client = chromadb.Client()
collection = client.get_or_create_collection("test-where-list")
collection.add(documents=["Article by john", "Article by Jack", "Article by Jill"],
               metadatas=[{"author": "john"}, {"author": "jack"}, {"author": "jill"}],
               ids=["1", "2", "3"])

res1 = collection.get(where={"$or": [{"author": "john"}, {"author": "jack"}]})
print(res1)

# And Logical Operator Filtering
collection = client.get_or_create_collection("test-where-list")
collection.upsert(documents=["Article by john", "Article by Jack", "Article by Jill"],
               metadatas=[{"author": "john","category":"chroma"}, {"author": "jack","category":"ml"}, {"author": "jill","category":"lifestyle"}], ids=["1", "2", "3"])
res2 = collection.get(where={"$and": [{"category": "chroma"}, {"author": "john"}]})
print(res2)

# And logical that doesn't match anything
res3 = collection.get(where={"$and": [{"category": "chroma"}, {"author": "jill"}]})
print(res3)

# Combined And and Or Logical Operator Filtering
res4 = collection.get(where={"$and": [{"category": "chroma"}, {"$or": [{"author": "john"}, {"author": "jack"}]}]})
print(res4)

res5 = collection.get(where_document={"$contains": "Article"},where={"$and": [{"category": "chroma"}, {"$or": [{"author": "john"}, {"author": "jack"}]}]})
print(res5)